import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入一级路由
// import Shop from '../views/Shop/shop.vue'
// import Management from '../views/Management/management.vue'
// import Control from '../views/Control/control.vue'
import Layout from '../views/Layout/index.vue';

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/Management/management',
    component: Layout,
  },
  {
    path: '/management',
    component: Layout,
    redirect: '/Management/management',
    meta: {
      title: '用户'
    },
    children: [
      // 用户
      {
        path: '/Management/management',
        component: () => import('../views/Management/management.vue'),
        meta: {
          title: '用户'
        },
      }
    ]
  },
  {
    path: '/control',
    component: Layout,
    redirect: '/Control/control',
    meta: {
      title: '选项卡'
    },
    children: [
      // 选项卡
      {
        path: '/Control/control',
        component: () => import('../views/Control/control.vue'),
        meta: {
          title: '选项卡'
        },
      }
    ]
  },
  {
    path: '/shop',
    component: Layout,
    redirect: '/Shop/shop',
    meta: {
      title: '购物'
    },
    children: [
      // 购物
      {
        path: '/Shop/shop',
        component: () => import('../views/Shop/shop.vue'),
        meta: {
          title: '购物'
        },
      }
    ]
  },
//  {
//    path:'/management',
//    Comment:Management
//  },
//  {
//    path:'/shop',
//    Comment:Shop
//  },
//  {
//    path:'/control',
//    Comment:Control
//  },

 
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})

export default router
